package com.atomscat.lottery.controller.admin;


import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;

@RestController
public class ImageController {
    @GetMapping(value = "/image/{name}", produces = MediaType.IMAGE_PNG_VALUE)
    public Mono<Resource> getImage(@PathVariable String name) {
        // 指定本地图片路径
        String path = "target/" + name;

        // 读取为Resource并返回
        Resource image = new FileSystemResource(path);
        return Mono.just(image);
    }
}
